package com.seari.controller;

import com.seari.annotation.AppCacheName;
import com.seari.pojo.MessageBean;
import com.seari.service.OperateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Map;

/**
 * @ClassName OperateController
 * @Description 运营
 * @Author LANDSUS
 * @Date 2021/5/14 18:08
 * @Version 1.0
 */
@RestController
public class OperateController {

    @Autowired
    private OperateService service;

    /**
     * @apiGroup 运营信息
     * @api {ALL} /operate 日常运营信息
     * @apiDescription 日常没有重大事件时的运营信息
     * @apiParamExample 请求示例
     * /operate
     * @apiSuccessExample 成功响应
     * HTTP/1.1 200
     * {
     *     "code": "200",
     *     "type": null,
     *     "message": null,
     *     "data": {
     *         "memo": "运营信息"
     *     },
     *     "total": 0
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("operate")
    @AppCacheName("operate")
    public MessageBean operateMessage(HttpServletRequest request){
        MessageBean result = new MessageBean();
        Map<String,Object> data = service.operateMessage();
        result.setData(data);
        result.setCode("200");
        return result;
    }

    /**
     * @apiGroup 运营信息
     * @api {ALL} /limitStation 限流车站
     * @apiDescription 重大事件限流车站信息
     * @apiParamExample 请求示例
     * /limitStation
     * @apiSuccessExample 成功响应
     * HTTP/1.1 200
     *{
     *     "code": "200",
     *     "type": null,
     *     "message": null,
     *     "data": {
     *         "limitStation": [   限流车站
     *             {
     *                 "stationNameCN": "江苏路",  车站名
     *                 "stationId": 1147   车站id
     *             },
     *         ],
     *         "limitSection": [   限流区间
     *             {
     *                 "beginStationId": "0129",   起始车站id
     *                 "endStationId": "0128",   结束车站id
     *                 "cType": 1  区间颜色，1绿色，2黄色，3红色（默认情况下为1绿色不显示）
     *             },
     *         ],
     *         "limitStationSize": 2   限流车站数
     *     },
     *     "total": 0
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("limitStation")
    @AppCacheName("limitStationAndSection")
    public MessageBean getLimitStation(HttpServletRequest request){
        MessageBean result = new MessageBean();
        Map<String,Object> data = service.getLimitStation();
        result.setData(data);
        result.setCode("200");
        return result;
    }

    /**
     * @apiGroup 天气
     * @api {ALL} /shangHaiWeather 上海全市天气信息
     * @apiDescription 上海全市天气信息
     * @apiParamExample 请求示例
     * /shangHaiWeather
     * @apiSuccessExample 成功响应
     * HTTP/1.1 200
     *{
     *     "code": "200",
     *     "type": null,
     *     "message": null,
     *     "data": 1,   天气类型：1晴、2雨、3阴
     *     "total": 0
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("shangHaiWeather")
    @AppCacheName("shangHaiWeather")
    public MessageBean shangHaiWeather(HttpServletRequest request){
        MessageBean result = new MessageBean();
        Integer data = service.shangHaiWeather();
        result.setData(data);
        result.setCode("200");
        return result;
    }

    /**
     * @apiGroup 总体规模
     * @api {ALL} /scaleSummarize 总体规模
     * @apiDescription 年累计客流量（亿人次、当日实时客流（万人次、实时在线车辆数（辆、实时平均满载率（百分比
     * @apiParamExample 请求示例
     * /scaleSummarize
     * @apiSuccessExample 成功响应
     * HTTP/1.1 200
     *{
     *     "code": "200",
     *     "type": null,
     *     "message": null,
     *     "data": {
     *         "annualFlow": "2900.44",    // 年累计客流量（亿
     *         "trulyFlow": "1234",        // 当日实时客流（万
     *         "onlineTrainNum": "100",    // 实时在线车辆数（辆
     *         "trulyAvgFullLoad": "50"    // 实时平均满载率（百分比
     *     },
     *     "total": 0
     * }
     * @apiVersion 0.0.1
     */
    @RequestMapping("scaleSummarize")
    @AppCacheName("scaleSummarize")
    public MessageBean scaleSummarize(HttpServletRequest request){
        MessageBean result = new MessageBean();
        Map<String,Object> data = service.scaleSummarize();
        result.setData(data);
        result.setCode("200");
        return result;
    }

}
